package homework;

public class leetcode36 {
    public boolean isSymmetric(TreeNode root) {
        if(root==null){
            return true;
        }
        return isbalance(root.left,root.right);
    }

    private boolean isbalance(TreeNode left, TreeNode right) {
        if(left==null&&right==null){
            return true;
        }
        if(left==null||right==null){
            return false;
        }
        if(left.val!=right.val){
            return false;
        }
        return isbalance(left.left,right.right)&&isbalance(left.right,right.left);
    }
}
